<!doctype html>
<html>
  <head>
    {% include global_head_assets.html %}

    {% comment %}
    Below, we're either dealing with a generic page or a page from the
    specification collection. For generic pages, we get a title just by
    reading page.title but, for specification pages, we build their title
    dynamically to take into account the page's version number and its
    relationship to the latest version.
    {% endcomment %}

    {% if page.is_spec_page %}
    {% assign class_spec='class="spec_page"' %}
    {% capture page_title %}
    {% include title_for_version.md is_latest_version=page.is_latest_version version=page.version %}
    {% endcapture %}
    {% else %}
    {% assign page_title = page.title %}
    {% endif %}
    <title>JSON:API &mdash; {{ page_title|strip }}</title>
  </head>

  <body {{ class_spec }}>
  {% include site_navigation.html %}
  {% if page.show_masthead %}
  <header>
    <div class="content">
      <h1 id="json-api">JSON:API</h1>
      <h2>A specification for building APIs in JSON</h2>
      <div class="quicklinks">
        {% for link in site.quicklinks %}
        <a href="{{link.url}}" title="{{link.title}}">{{link.title}}</a>
        {% endfor %}
          </div>
          {% if site.announcement %}
          <div class="announcement">
            {{ site.announcement|markdownify }}
          </div>
          {% endif %}
        </div>
      </header>
    {% endif %}
    <div class="site-wrapper">
      {% if page.show_sidebar %}
        <div class="sidebar">
          <nav class="document-outline" id="document-outline">
            {% comment %}
              Substitute the version picker for the sidebar title on spec pages.
            {% endcomment %}
            {% if page.is_spec_page %}
              <div id="version-picker-wrapper" class="sidebar-top">
                <label for="version-picker">Version: </label>
                <select class="version-picker" id="version-picker">
                  <option value="/format/"
                    {% if page.is_latest_version %}selected{% endif %}
                  >
                    Latest Version (v{{ site.latest_version }})
                  </option>
                  <option
                    value="/format/{{ site.latest_version|plus:0.1 }}/"
                    {% if page.version > site.latest_version %}selected{% endif %}
                  >
                    Upcoming Version (v{{ site.latest_version|plus:0.1 }})
                  </option>
                  <optgroup label="Old Versions/Permalinks">
                    {% assign sorted_formats = site.format|sort:'version' %}
                    {% for spec_draft in sorted_formats %}
                      {% if spec_draft.version <= site.latest_version and spec_draft.path contains 'index' %}
                        <option value="/format/{{spec_draft.version}}"
                          {% if page.version == spec_draft.version %}selected{% endif%}
                        >
                          v{{spec_draft.version}}
                        </option>
                      {%endif %}
                    {% endfor %}
                  </optgroup>
                </select>
              </div>
            {% else %}
              <h1 class="sidebar-top">{{ page_title }}</h1>
            {% endif %}
          </nav>
        </div>
      {% endif %}
      <main class="content">
        {% unless page.show_masthead %}
          <h1>
            {{ page_title }}
          </h1>
        {% endunless %}
        <section>
          {% if page.is_spec_page %}
            {% capture status %}
              {% include status.md release_date=page.release_date status=page.status version=page.version is_latest_version=page.is_latest_version %}
            {% endcapture %}
            {{ status|strip|markdownify }}
          {% endif %}
          {{ content }}
        </section>
      </main>
    </div>
    {% include global_html_footer.html %}
  </body>

</html>
